package com.cy.personer.biz.impl;

import com.cy.personer.bean.Desk;
import com.cy.personer.biz.DeskBiz;
import com.cy.personer.mapper.DeskMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 科室服务层实现类
 * @author 林少艺
 */
@Service
public class DeskBizImpl implements DeskBiz {

    @Resource
    DeskMapper deskMapper;

    /**
     * 查询科室列表
     * @param desk
     * @return
     * @author 林少艺
     */
    @Override
    public List<Desk> getDesks(Desk desk) {
        return deskMapper.getDesks(desk);
    }

    //查询所有科室
    @Override
    public List<Desk> findAllDesk() {
        return deskMapper.findAllDesk();
    }

    @Override
    public boolean add(Desk desk) {
        return deskMapper.add(desk);
    }

    @Override
    public boolean update(Desk desk) {
        return deskMapper.update(desk);
    }

    @Override
    public boolean del(int deskId) {
        try {
            boolean state = deskMapper.del(deskId);
            return state;
        }
        catch (Exception e){
            return false;
        }

    }

    @Override
    public  PageInfo<Desk> findDesk(Integer pageNum) {
        PageHelper.startPage(pageNum,5);
        List<Desk> quer = deskMapper.findDesk();
        PageInfo<Desk> PageInfo = new PageInfo<>(quer);
        return PageInfo;
    }
}
